06. Introduction to Curl and Chrome Dev Tools

Introduction to Curl and Chrome Dev Tools

Chrome Dev Tools

FSND C2 L2 A09 Introduction To Curl And Chrome Dev Tools Part 1

If you want to check how your requests are being sent, and what the responses are from the browser, you can do so using Chrome Dev Tools . There are numerous tools within it, but the key area you'll use is the Network tab.

To access the Network tab, open developer tools ( Cmd + Shift + C or Hamburger Menu → More Tools → Developer Tools ). Then select the Network tab. Any requests that are made after Developer Tools has been opened will show up on this tab.

Curl

FSND C2 L2 A10 Introduction To Curl And Chrome Dev Tools Part 2

Curl is a library and command line tool that completes IP transfers of data using URLs. One quick way to test your API while your API server is running is to run a curl command in another terminal window.

Curl Syntax

curl -X POST http://www.example.com/tasks/

The above is a sample curl request. Every request starts off with the command curl and needs to include a URL. Other parts you see added in are options that you can use to build your request. In the example the -X shortform option (also --request ) specifies the request method.

FSND C2 L2 A11 Introduction To Curl And Chrome Dev Tools Part 3

Curl Options

You can find more options by entering curl --help in the terminal. Some frequently used options are:

  • -X or --request COMMAND
  • -d or --data DATA
  • -F or --form CONTENT
  • -u or --user USER[:PASSWORD]
  • -H or --header LINE

Curl Quiz 1

Using curl in your command line, make a get request to https://pokeapi.co/api/v2/move/47 of the PokeAPI . Which of the following is the accuracy value of the move?

SOLUTION: 55

Which endpoint(s) of the PokeAPI should you use to get information about the Master Ball, which is an item in Pokemon. Review the documentation before attempting to answer

SOLUTION:
  • /api/v2/item/master-ball
  • /api/v2/item/1

Which elements of the sample curl request below are optional?

curl -X GET https://pokeapi.co/api/v2/move/47

SOLUTION:
  • -X
  • GET